package util;

import java.util.regex.Matcher;

import junit.framework.Assert;

import org.junit.Test;
import org.taobao.ibatiside.ui.util.MiscHelper;

public class TestUtil {

	@Test
	public void test() {
		String a1="createAbc";
		Assert.assertEquals("CREATE_ABC",MiscHelper.getConstName(a1));
		String a2="CreateAbc";
		Assert.assertEquals("CREATE_ABC",MiscHelper.getConstName(a2));
		String a3="createABC";
		Assert.assertEquals("CREATE_ABC",MiscHelper.getConstName(a3));
	}
	@Test
	public void filePattern(){
		String fn1 = "/a/b/c/dao-interface-default.javajet";
		Assert.assertEquals(true, MiscHelper.DAO_API_PATTERN.matcher(fn1).find());
		Matcher m = MiscHelper.DAO_API_PATTERN.matcher(fn1);
		Assert.assertEquals(true, m.find());
		Assert.assertEquals("default", m.group(1));
		String sid1 = "abc_def";
		String sid2 = "abc$CHILD";
		String jid1 = MiscHelper.sqlId2JavaId(sid1);
		Assert.assertEquals("abcDef", jid1);
		jid1 = MiscHelper.sqlId2JavaId(sid2);
		Assert.assertEquals("abcChild", jid1);
		String sid3 = "class";
		jid1 = MiscHelper.sqlId2JavaId(sid3);
		Assert.assertEquals("class0", jid1);
	}

}
